import { $get, $post, $del, $put } from 'utils/request'
import { getUserInfo } from 'utils/headerToken'
const basics = 'zcvd'

/**
 *  个人中心
 * */
// 全部流程列表
export let instanceManageList = async (params) => {
  let url = `$zwkf/v1/$tenantId/instance-manage`
  let data = await $get(url, params)
  return data
}

// 获取待办列表
export let flowtaskTodoList = async (params) => {
  let url = `$zwkf/v1/$tenantId/flow-task/todo`
  let data = await $get(url, params)
  return data
}
// 获取已办列表
export let flowtaskDoneList = async (params) => {
  let url = `$zwkf/v1/$tenantId/flow-task/done`
  let data = await $get(url, params)
  return data
}

// 获取任务详情
export let flowtaskDetail = async (processInstanceId, params) => {
  let url = `$zwkf/v1/$tenantId/flow-task/detail/${processInstanceId}`
  let data = await $get(url, params)
  return data
}
// 获取流程变量
export let flowtaskProcessVariables = async (processInstanceId) => {
  let url = `$zwkf/v1/$tenantId/flow-task/processVariables/${processInstanceId}`
  let data = await $get(url)
  return data
}
// 审批任务
export let flowtaskComplete = async (params) => {
  let url = `$zwkf/v1/$tenantId/flow-task/complete`
  let data = await $post(url, params)
  return data
}
// 拒绝任务
export let flowtaskReject = async (params) => {
  let url = `$zwkf/v1/$tenantId/flow-task/reject`
  let data = await $post(url, params)
  return data
}
// 终止任务
export let flowtaskTermination = async (params) => {
  let url = `$zwkf/v1/$tenantId/flow-task/termination`
  let data = await $post(url, params)
  return data
}

// new 接口===
// 同意并加签
// 批准
export let processApproveTaskPassApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/pass`
  let data = await $post(url, params)
  return data
}
// 拒绝
export let processApproveTaskRefuseApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/refuse`
  let data = await $post(url, params)
  return data
}
// 转交
export let processApproveTasktRansferApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/transfer`
  let data = await $post(url, params)
  return data
}
// 同意并加签
export let agreeAndAddSignApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/agree-and-add-sign`
  let data = await $post(url, params)
  return data
}
// 抄送
export let processApproveTaskCcApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/cc`
  let data = await $post(url, params)
  return data
}

// 旧前加签
export let processApproveTaskpreAddSignApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/pre-add-sign`
  let data = await $post(url, params)
  return data
}
// 新前加签
export let beforeSignApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/before-sign`
  let data = await $post(url, params)
  return data
}
// 新后加签
export let afterSignApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/after-sign`
  let data = await $post(url, params)
  return data
}

// 驳回
export let processApproveTaskRejectApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/reject`
  let data = await $post(url, params)
  return data
}
// 搜索条件【业务单据】下拉数据 // 流程定义-根据租户查询单据Code-filter:true-过滤已配置过审批流的code;filter:false-全部
export let listDocConfigCodeFilterApi = async (filter) => {
  let url = `$zwkf/v1/$tenantId/doc-config/listDocConfigCode/${filter}`
  let data = await $get(url, {})
  return data
}
// 获取已审批列表
export let alreadyApproveListApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/already-approve/${getUserInfo().empId || ''}`
  let data = await $get(url, params)
  return data
}
// 获取待审批列表
export let waitingApproveListApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/waiting-approve/${getUserInfo().empId || ''}`
  let data = await $get(url, params)
  return data
}

// 获取待审批列表数
export let getWaitingApproveCountApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/${getUserInfo().empId || ''}/waiting-approve-count`
  let data = await $get(url, {})
  return data
}

// 获取我提交的列表
export let mySubmittedListApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/my-submitted/${getUserInfo().empId || ''}`
  let data = await $get(url, params)
  return data
}
// 我提交的-撤回
export let mySubmittedRevokeApi = async (params, processInstanceId) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/revoke/${processInstanceId}`
  let data = await $post(url, params)
  return data
}
// 获取我提交的列表
export let ccMyListApi = async (params) => {
  let url = `$zwkf/v1/$tenantId/process-cc-task/cc-my/${getUserInfo().empId || ''}`
  let data = await $get(url, params)
  return data
}
// 获取审批详情
export let getApproveDetailApi = async (params, instanceId) => {
  let url = `$zwkf/v1/$tenantId/process-approve-task/approveDetail/${instanceId}`
  let data = await $get(url, params)
  return data
}
// 获取对应流程实例运行时变量- 审批表单的 大对象值
export let getprocessRuntimeVariableApi = async (params, processInstanceId) => {
  let url = `$zwkf/v1/$tenantId/process-runtime-variable/${processInstanceId}`
  let data = await $get(url, params)
  return data
}

/**
 *  员工管理
 * */

// 员工管理-员工列表
export let getEmpApi = async (params) => {
  let url = `$zemd/v1/$tenantId/emp`
  let data = await $get(url, params)
  return data
}
// 单据配置字段表列表 根据docConfigCode请求
export let docConfigCodelineList = async (params) => {
  let url = `$zwkf/v1/$tenantId/doc-config/byCode`
  let data = await $get(url, params)
  return data
}

export let getVendorKpiDetailByIdApi = async (params) => {
  let url = `/${basics}/v1/$tenantId/vendorKpiTask/vendorKpiDetail/${params.kpiTaskId}/${params.vendorId}`
  let data = await $get(url, params)
  return data
}

// 绩效考核模版详情=>
export let getExamineTmplByIdApi = async (id) => {
  let url = `/${basics}/v1/$tenantId/vendorKpiExamineTmpl/details/${id}`
  let data = await $get(url, id)
  return data
}

// 根据寻源查询已关联单据
export let getFindBySourcing = async (params) => {
  let url = `/zrfx/v1/$tenantId/sourcingBusinessRelation/findBySourcing`
  let data = await $post(url, params)
  return data
}
